﻿using MiscUtil;

namespace CI.Models
{
    public static class Extensions
    {
        public static T MultiplyByInt<T>(T val, int multiplier)
        {
            var running = val;
            for (var i = 0; i < multiplier - 1; i++)
                running = Operator<T>.Add(running, val);
            return running;
        }

        public static int FindIntegerFactor<T>(T val, T threshold)
        {
            var running = val;
            var factor = 1;
            while (Operator.LessThan(running, threshold))
            {
                running = Operator<T>.Add(running, val);
                factor++;
            }
            return factor;
        }
    }
}